﻿using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using YiSha.Business.YiDongYuan;
using YiSha.Entity.YiDongYuan;
using YiSha.Model.Param.YiDongYuan;
using YiSha.Util.Model;

namespace YiSha.Admin.WebApi.Controllers
{
    /// <summary>
    /// 库存号牌
    /// </summary>
    [Route("[controller]/[action]")]
    [ApiController]
    [AuthorizeFilter]
    public class PlateController : ControllerBase
    {
        private SparePlateBLL sparePlateBLL = new SparePlateBLL();
        private DetectionMechanicsBLL detectionMechanicsBLL = new DetectionMechanicsBLL();

        /// <summary>
        /// 获取库存号牌列表
        /// </summary>
        /// <param name="param"></param>
        /// <param name="pagination"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<TData<List<SparePlateEntity>>> GetPageList([FromQuery] long id)
        {
            var mechanics = await detectionMechanicsBLL.GetEntity(id);
            string region = mechanics.Data.HuanBaoCode.Substring(5, 1);
            var param = new SparePlateListParam() { keywords = $"{mechanics.Data.PFJD}-408{region}" };
            TData<List<SparePlateEntity>> obj = await sparePlateBLL.GetList(param);
            return obj;
        }
    }
}
